home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / Apache 1.0 / src / http_protocol.h < prev    next >
Text File  |  1995-12-04  |  7KB  |  162 lines

  1.  
  2. /* ====================================================================
  3.  * Copyright (c) 1995 The Apache Group.  All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that the following conditions
  7.  * are met:
  8.  *
  9.  * 1. Redistributions of source code must retain the above copyright
  10.  *    notice, this list of conditions and the following disclaimer. 
  11.  *
  12.  * 2. Redistributions in binary form must reproduce the above copyright
  13.  *    notice, this list of conditions and the following disclaimer in
  14.  *    the documentation and/or other materials provided with the
  15.  *    distribution.
  16.  *
  17.  * 3. All advertising materials mentioning features or use of this
  18.  *    software must display the following acknowledgment:
  19.  *    "This product includes software developed by the Apache Group
  20.  *    for use in the Apache HTTP server project (http://www.apache.org/)."
  21.  *
  22.  * 4. The names "Apache Server" and "Apache Group" must not be used to
  23.  *    endorse or promote products derived from this software without
  24.  *    prior written permission.
  25.  *
  26.  * 5. Redistributions of any form whatsoever must retain the following
  27.  *    acknowledgment:
  28.  *    "This product includes software developed by the Apache Group
  29.  *    for use in the Apache HTTP server project (http://www.apache.org/)."
  30.  *
  31.  * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
  32.  * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  33.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  34.  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE APACHE GROUP OR
  35.  * IT'S CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  36.  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  37.  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  38.  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  39.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  40.  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  41.  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  42.  * OF THE POSSIBILITY OF SUCH DAMAGE.
  43.  * ====================================================================
  44.  *
  45.  * This software consists of voluntary contributions made by many
  46.  * individuals on behalf of the Apache Group and was originally based
  47.  * on public domain software written at the National Center for
  48.  * Supercomputing Applications, University of Illinois, Urbana-Champaign.
  49.  * For more information on the Apache Group and the Apache HTTP server
  50.  * project, please see <http://www.apache.org/>.
  51.  *
  52.  */
  53.  
  54.  
  55. /*
  56.  * Prototypes for routines which either talk directly back to the user,
  57.  * or control the ones that eventually do.
  58.  */
  59.  
  60. /* Read a request and fill in the fields. */
  61.  
  62. request_rec *read_request (conn_rec *c);     
  63.  
  64. /* Send header for http response */
  65.  
  66. void send_http_header (request_rec *l);     
  67.      
  68. /* Send error back to client... last arg indicates error status in case
  69.  * we get an error in the process of trying to deal with an ErrorDocument
  70.  * to handle some other error.  In that case, we print the default report
  71.  * for the first thing that went wrong, and more briefly report on the
  72.  * problem with the ErrorDocument.
  73.  */
  74.  
  75. void send_error_response (request_rec *r, int recursive_error);
  76.      
  77. /* Set last modified header line from the lastmod date of the associated file.
  78.  * Also, set content length.
  79.  *
  80.  * May return an error status, typically USE_LOCAL_COPY (that when the
  81.  * permit_cache argument is set to one).
  82.  */
  83.  
  84. int set_content_length (request_rec *r, long length);
  85. int set_last_modified (request_rec *r, time_t mtime);
  86.  
  87. void add_env_var (array_header *env, char *header_name, char *val);
  88.  
  89. /* Other ways to send stuff at the client.  All of these keep track
  90.  * of bytes_sent automatically.  This indirection is intended to make
  91.  * it a little more painless to slide things like HTTP-NG packetization
  92.  * underneath the main body of the code later.  In the meantime, it lets
  93.  * us centralize a bit of accounting (bytes_sent).
  94.  *
  95.  * These also return the number of bytes written by the call.
  96.  * They should only be called with a timeout registered, for obvious reaasons.
  97.  * (Ditto the send_header stuff).
  98.  */
  99.  
  100. long send_fd(FILE *f, request_rec *r);
  101.      
  102. /* Hmmm... could macrofy these for now, and maybe forever, though the
  103.  * definitions of the macros would get a whole lot hairier.
  104.  */
  105.      
  106. long rprintf (request_rec *r, char *s, ...);     
  107. int rputc (int c, request_rec *r);     
  108.      
  109. /*
  110.  * Index used in custom_responses array for a specific error code
  111.  * (only use outside protocol.c is in getting them configured).
  112.  */
  113.  
  114. int index_of_response (int status);
  115.  
  116. /* Reading a block of data from the client connection (e.g., POST arg) */
  117.      
  118. long read_client_block (request_rec *r, char *buffer, int bufsiz);
  119.      
  120. /* Finally, this charming little number is here to encapsulate the
  121.  * degree to which nph- scripts completely escape from any discipline
  122.  * the protocol code might care to impose (this as opposed to other
  123.  * scripts, which *partially* escape to the extent that they may try
  124.  * to explicitly set the status line).
  125.  */
  126.  
  127. void client_to_stdout (conn_rec *c); 
  128.  
  129.  
  130. /* Support for the Basic authentication protocol.  Note that there's
  131.  * nothing that prevents these from being in mod_auth.c, except that other
  132.  * modules which wanted to provide their own variants on finding users and
  133.  * passwords for Basic auth (a fairly common request) would then require
  134.  * mod_auth to be loaded or they wouldn't work.
  135.  *
  136.  * get_basic_auth_pw returns 0 (OK) if it set the 'pw' argument (and assured
  137.  * a correct value in r->connection->user); otherwise it returns an error
  138.  * code, either SERVER_ERROR if things are really confused, AUTH_REQUIRED
  139.  * if no authentication at all seemed to be in use, or DECLINED if there
  140.  * was authentication but it wasn't Basic (in which case, the caller should
  141.  * presumably decline as well).
  142.  *
  143.  * note_basic_auth_failure arranges for the right stuff to be scribbled on
  144.  * the HTTP return so that the client knows how to authenticate itself the
  145.  * next time.
  146.  */
  147.  
  148. void note_basic_auth_failure(request_rec *r);
  149. int get_basic_auth_pw (request_rec *r, char **pw);
  150.  
  151. /*
  152.  * Setting up the protocol fields for subsidiary requests...
  153.  * Also, a wrapup function to keep the internal accounting straight.
  154.  */
  155.  
  156. void set_sub_req_protocol (request_rec *rnew, request_rec *r);
  157. void finalize_sub_req_protocol (request_rec *sub_r);
  158.  
  159. /* This is also useful for putting sub_reqs and internal_redirects together */
  160.  
  161. void parse_uri (request_rec *r, char *uri);     
  162.